package com.itheima.web.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.ServletException;
import java.io.IOException;

/**
 * @author huyoufu <https://github.com/huyoufu>
 * @TIME 2020-08-11 09:37
 * @description
 *
 * 采用modelAndView 定制化 视图解析器
 */


@Controller
@RequestMapping("/user03")
public class demo3_modelAndView视图解析器 {

    @RequestMapping("/login.do")
    public ModelAndView login( ModelAndView modelAndView) throws ServletException, IOException {
        System.out.println("用户登录...");

        //响应信息

        //springmvc框架提供了对象

        modelAndView.addObject("info","模拟的登录数据");
        modelAndView.setViewName("user/success");

        return modelAndView;
    }

    @RequestMapping("/register.do")
    public ModelAndView register(ModelAndView modelAndView) throws ServletException, IOException {
        System.out.println("用户注册...");


        modelAndView.addObject("info","模拟的注册数据");
        modelAndView.setViewName("user/success");

        return modelAndView;

    }

    @RequestMapping("/logout.do")
    public ModelAndView logout(ModelAndView modelAndView) throws ServletException, IOException {
        System.out.println("退出登录...");

        modelAndView.addObject("info","模拟的推出登录数据");
        modelAndView.setViewName("user/success");

        return modelAndView;

    }
}
